package entity.file;

import java.io.File;
import java.io.FileReader;

/**
 * @author ：mmzs
 * @date ：Created in 2020/9/14 10:50
 * @description：
 * @modified By：
 * @version: $
 */
@Deprecated
public class TxtFile extends AbstractFile{

    public TxtFile(int id, File file) {
        this.id = id;
        this.file = file;
        this.path = file.getPath();
    }

    @Override
    public String loadTextFromFile() {
        String result = null;
        try {
            FileReader fileReader = new FileReader(file);
            int ch = 0;
            StringBuffer stringBuffer = new StringBuffer();
            while ((ch = fileReader.read()) != -1) {
                if (((char) ch) != '\r') {
                    stringBuffer.append((char) ch);
                }
            }
            result = stringBuffer.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
